﻿using System.Web.Mvc;
using SlamCms.Data;
using SlamCms.Web.Mvc;

namespace SlamCms.Areas._admin.Controllers
{
	[AuthorizeTo(Constants.Groups.FrontEndAdministrators)]
	public abstract class AdminBaseController : Controller
	{
		protected override void OnActionExecuting(ActionExecutingContext filterContext)
		{
			if (filterContext.IsChildAction)
				return;

			// use the controller name as default for the tab selection
			var controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
			SetCurrentTab(controllerName);

			base.OnActionExecuting(filterContext);
		}

		protected void SetCurrentTab(string key)
		{
			ViewData["AdminTabSelected"] = key;
		}
	}
}
